//
//  DDDADSDKViewController.m
//  DDDAdSdk
//
//  Created by summerthread on 09/18/2020.
//  Copyright (c) 2020 summerthread. All rights reserved.
//

#import "DDDADSDKViewController.h"
#import "MBProgressHUD.h"
#import "DDDNativeExpressRewaredVideoVC.h"
#import "DDDExpressCusDrawVC.h"
#import "DDDExpressFullScreenVC.h"
#import "DDDExpressInterstitialVC.h"
#import "DDDBannerListVC.h"
#import "DDDInterstitialListVC.h"
#import <DDDAdSdk/DDDAdSdk.h>
#import "DDDFullScreenListVC.h"
#import "DDDFeedListVC.h"


@interface DDDADSDKViewController ()

@property (nonatomic, strong) UIButton *playBtn;
@property (nonatomic, strong) UIButton *nextBtn;
@property (nonatomic, strong) UIButton *feedBtn;

@property (nonatomic, strong) UIButton *bannerBtn;

@property (nonatomic, strong) UIButton *fullScreenBtn;

@property (nonatomic, strong) UIButton *gameBtn;

@property (nonatomic, strong) UIButton *InterstitialOneBtn;

@property (nonatomic, strong) UIButton *sprotGameBtn;

@end

@implementation DDDADSDKViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"广告控制器";
    
    CGFloat nextBtnW = 280.0;
    CGFloat nextBtnH = 45.0;
    CGFloat nextBtnX = ([UIScreen mainScreen].bounds.size.width - nextBtnW) * 0.5;
    CGFloat nextBtnY = 150.0;
    [self.view addSubview:self.nextBtn];
    self.nextBtn.frame = CGRectMake(nextBtnX, nextBtnY, nextBtnW, nextBtnH);
    
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.playBtn];
    self.playBtn.frame = CGRectMake(nextBtnX, nextBtnY, nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.bannerBtn];
    self.bannerBtn.frame = CGRectMake(nextBtnX, nextBtnY, nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.feedBtn];
    self.feedBtn.frame = CGRectMake(nextBtnX, nextBtnY , nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.fullScreenBtn];
    self.fullScreenBtn.frame = CGRectMake(nextBtnX, nextBtnY , nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.gameBtn];
    self.gameBtn.frame = CGRectMake(nextBtnX, nextBtnY , nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.InterstitialOneBtn];
    self.InterstitialOneBtn.frame = CGRectMake(nextBtnX, nextBtnY, nextBtnW, nextBtnH);
    nextBtnY = nextBtnY + nextBtnH + 20.0;
    [self.view addSubview:self.sprotGameBtn];
    self.sprotGameBtn.frame = CGRectMake(nextBtnX, nextBtnY, nextBtnW, nextBtnH);
}

#pragma mark - 点击事件
- (void)clickBtnAction:(UIButton *)sender {
    switch (sender.tag) {
        case 10:
        {
            DDDNativeExpressRewaredVideoVC *vc = [[DDDNativeExpressRewaredVideoVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 20:
        {
            DDDExpressCusDrawVC *vc = [[DDDExpressCusDrawVC alloc]init];
            vc.modalPresentationStyle = UIModalPresentationFullScreen;
            [self presentViewController:vc animated:YES completion:nil];
        }
            break;
        case 30:
        {
            DDDBannerListVC *vc = [[DDDBannerListVC alloc]init];
        //    DDDExpressBannerVC *vc = [[DDDExpressBannerVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 40:
        {
            DDDFeedListVC *vc = [[DDDFeedListVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 50:
        {
            DDDFullScreenListVC *vc = [[DDDFullScreenListVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 60:
        {
            //game
            [DDDAdGameManager presentListViewController:self userId:@"123456" advertType:0];
        }
            break;
        case 70:
        {
            DDDInterstitialListVC *vc = [[DDDInterstitialListVC alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 80:
        {
            [DDDSportGameManager presentListViewController:self andTitleName:@"互动广告"];
        }
            break;
            
        default:
            break;
    }
}



#pragma mark - 懒加载
- (UIButton *)nextBtn {
    if (!_nextBtn) {
        _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_nextBtn setTitle:@"激励视频" forState:UIControlStateNormal];
        [_nextBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_nextBtn setBackgroundColor:[UIColor redColor]];
        _nextBtn.layer.masksToBounds = YES;
        _nextBtn.layer.cornerRadius = 8.0;
        _nextBtn.tag = 10;
    }
    return _nextBtn;
}

- (UIButton *)playBtn {
    if (!_playBtn) {
        _playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_playBtn setTitle:@"draw信息流" forState:UIControlStateNormal];
        [_playBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_playBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_playBtn setBackgroundColor:[UIColor redColor]];
        _playBtn.layer.masksToBounds = YES;
        _playBtn.layer.cornerRadius = 8.0;
        _playBtn.tag = 20;
    }
    return _playBtn;
}
- (UIButton *)bannerBtn {
    if (!_bannerBtn) {
        _bannerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_bannerBtn setTitle:@"banner" forState:UIControlStateNormal];
        [_bannerBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_bannerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_bannerBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _bannerBtn.layer.masksToBounds = YES;
        _bannerBtn.layer.cornerRadius = 8.0;
        _bannerBtn.tag = 30;
    }
    return _bannerBtn;
}
- (UIButton *)feedBtn {
    if (!_feedBtn) {
        _feedBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_feedBtn setTitle:@"信息流" forState:UIControlStateNormal];
        [_feedBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_feedBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_feedBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _feedBtn.layer.masksToBounds = YES;
        _feedBtn.layer.cornerRadius = 8.0;
        _feedBtn.tag = 40;
    }
    return _feedBtn;
}

- (UIButton *)fullScreenBtn {
    if (!_fullScreenBtn) {
        _fullScreenBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_fullScreenBtn setTitle:@"全屏广告" forState:UIControlStateNormal];
        [_fullScreenBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_fullScreenBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_fullScreenBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _fullScreenBtn.layer.masksToBounds = YES;
        _fullScreenBtn.layer.cornerRadius = 8.0;
        _fullScreenBtn.tag = 50;
    }
    return _fullScreenBtn;
}


- (UIButton *)gameBtn {
    if (!_gameBtn) {
        _gameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_gameBtn setTitle:@"游戏广告" forState:UIControlStateNormal];
        [_gameBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_gameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_gameBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _gameBtn.layer.masksToBounds = YES;
        _gameBtn.layer.cornerRadius = 8.0;
        _gameBtn.tag = 60;
    }
    return _gameBtn;
}
- (UIButton *)InterstitialOneBtn {
    if (!_InterstitialOneBtn) {
        _InterstitialOneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_InterstitialOneBtn setTitle:@"插屏广告" forState:UIControlStateNormal];
        [_InterstitialOneBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_InterstitialOneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_InterstitialOneBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _InterstitialOneBtn.layer.masksToBounds = YES;
        _InterstitialOneBtn.layer.cornerRadius = 8.0;
        _InterstitialOneBtn.tag = 70;
    }
    return _InterstitialOneBtn;
}
- (UIButton *)sprotGameBtn {
    if (!_sprotGameBtn) {
        _sprotGameBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sprotGameBtn setTitle:@"互动广告" forState:UIControlStateNormal];
        [_sprotGameBtn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_sprotGameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_sprotGameBtn setBackgroundColor:[UIColor redColor]];
//        _playBtn.userInteractionEnabled = NO;
        _sprotGameBtn.layer.masksToBounds = YES;
        _sprotGameBtn.layer.cornerRadius = 8.0;
        _sprotGameBtn.tag = 80;
    }
    return _sprotGameBtn;
}
@end
